﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DataBroker.Dao;

namespace OraHRDAO
{
    [Serializable]
    public class MANAGERS : EMPLOYEES
    {
        public override string TableName()
        {
            return "EMPLOYEES";
        }

		///Default constructor
        public MANAGERS()
		{
		
		}
        /// <summary>
        /// Constructor for joins. 
		/// Available CHILD tables to join with:
		///    - EMPLOYEES ( EMPLOYEES_EMP_MANAGER_FK )
		/// Available PARENT tables to join with:
		///    - DEPARTMENTS
		///    - JOBS
		///    - EMPLOYEES
        /// </summary>
        public MANAGERS(bool Flat, params Entity[] entities)
            : base(Flat, entities)
        {
        }

		///Constructor for Joins with flat hierarchy
        public MANAGERS(params Entity[] entities)
            : this(true, entities)
		{
		}

        #region EMPLOYEES
        private EntityCollection _EMPLOYEES;
        ///<summary>
        /// Related table EMPLOYEES as a collection for hierarchical retrieval.
        ///</summary>
        [NotInTable]
        [TypeContainedAttribute(typeof(EMPLOYEES), "EMPLOYEES")]
        public EntityCollection EMPLOYEES
        {
            get
            {
                return _EMPLOYEES;
            }

            set
            {
                _EMPLOYEES = value;
            }
        }
        private EMPLOYEES _EMPLOYEES_;
        ///<summary>
        /// Related table EMPLOYEES as a single object for flat retrieval.
        ///</summary>
        [NotInTable]
        public EMPLOYEES EMPLOYEES_
        {
            get
            {
                return _EMPLOYEES_;
            }

            set
            {
                _EMPLOYEES_ = value;
            }
        }
        #endregion

        /// <summary>
        /// Gets join for current entity and table.
        /// </summary>
        /// <param name="tableName">Table to join with entity.</param>
        /// <returns>Join definition for entity and table.</returns>
        public override DBJoin GetJoin(string tableName)
        {
            if (string.Compare(tableName, "EMPLOYEES", true) == 0)
            {
                ArrayList left = new ArrayList();
                ArrayList right = new ArrayList();
                left.Add(tableName + ".EMPLOYEE_ID");
                right.Add(GetType().Name + ".MANAGER_ID");
                return new DBJoin(left, right, JoinTypeEnumeration.LEFT_OUTER);
            }
            return null;
        }
    }
}
